#include <gtest/gtest.h>

#include <algorithm>
#include <set>
#include <vector>

#include "algorithm/common/include/permutation.h"
TEST(TestPerm, PermutationSuit) {
  std::vector<int> a = {0, 1, 2};
  std::set<std::vector<int>> std_result;
  std::vector<std::vector<int>> m_result = permute(a);
  //  std_result.insert(a);
  //  while (std::next_permutation(a.begin(), a.end())) {
  //    std_result.insert(a);
  //  };
  //
  //  EXPECT_EQ(m_result.size(), std_result.size());
  //  for (auto e : m_result) {
  //    EXPECT_EQ(std_result.count(e), 1);
  //  }
  //
  //  a = {0, -1, 1};
  //  m_result = permute(a);
  //  std_result = {{0, -1, 1}, {0, 1, -1}, {-1, 0, 1},
  //                {-1, 1, 0}, {1, 0, -1}, {1, -1, 0}};
  //
  //  EXPECT_EQ(m_result.size(), std_result.size());
  //  for (auto e : m_result) {
  //    EXPECT_EQ(std_result.count(e), 1);
  //  }

  a = {1, 2, 3};
  m_result = permute(a);
  std_result = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3},
                {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};

  EXPECT_EQ(m_result.size(), std_result.size());
  for (auto e : m_result) {
    for (auto i : e) {
      std::cerr << i << " ";
    }
    std::cerr << "\n";
  }
  for (auto e : m_result) {
    EXPECT_EQ(std_result.count(e), 1);
  }
}
